import request from '@/utils/request'

//  获取商品分页列表
export function listGoods(query){
  return request({
    url: '/manager/goods/goods/list',
    method: 'get',
    params: query
  })
}
//  下架商品
export function underGoods(data){
  return request({
    url: '/manager/goods/goods/under',
    method: 'post',
    data: data
  })
}
//  上架商品
export function upGoods (data){
  return request({
    url: '/manager/goods/goods/up',
    method: 'post',
    data: data
  })
}

//  获取待审核商品分页列表
export function getAuthGoodsListData(query){
  return request({
    url: '/manager/goods/goods/auth/list',
    method: 'get',
    params: query
  })
}

//查看商品详情
export function getGoodsDetail(id){
  return request({
    url: '/manager/goods/goods/get/' + id,
    method: 'get',
  })
}


//  获取商品sku分页列表
export function getGoodsSkuData(query){
  return request({
    url: '/manager/goods/goods/sku/list',
    method: 'get',
    params: query
  })
}

//  审核商品
export function authGoods (data){
  return request({
    url: '/manager/goods/goods/auth',
    method: 'post',
    data: data
  })
}


//  新增商品
export function createGoods (data){
  return request({
    url: '/manager/goods/goods/create',
    method: 'post',
    data: data
  })
}


//  修改商品
export function editGoods (data){
  return request({
    url: '/manager/goods/goods/edit',
    method: 'put',
    data: data
  })
}



//根据分类id获取关联品牌
export const getCategoryBrandListData = (category_id, params) => {
    return getRequest(`/manager/goods/categoryBrand/${category_id}`, params)
}
//保存获取关联品牌
export const saveCategoryBrand = (category_id, params) => {
    return postRequest(`/manager/goods/categoryBrand/${category_id}`, params)
}
//保存获取关联规格
export const saveCategorySpec = (category_id, params) => {
    return postRequest(`/manager/goods/categorySpec/${category_id}`, params)
}

//获取所有可用品牌
export const getBrandListData = (params) => {
    return getRequest('/manager/goods/brand/all', params)
}
// 获取所有可用规格
export const getSpecificationList = (params) => {
    return getRequest('/manager/goods/spec/all', params)
}

//获取分类列表数据
export const getAllCategoryList = (parent_id) => {
  return getRequest(`/manager/goods/category/${parent_id}/all-children`)
}





//根据分类id获取关联规格
export const getCategorySpecListData = (category_id, params) => {
    return getRequest(`/manager/goods/categorySpec/${category_id}`, params)
}
//删除gUI个
export const delSpec = (id, params) => {
    return deleteRequest(`/manager/goods/spec/${id}`, params)
}

// 查询某分类下的全部子分类列表
export const getGoodsCategory = (parent_id) => {
    return getRequest(`/manager/goods/category/${parent_id}/all-children`)
}









//查询分类绑定参数信息
export const getCategoryParamsListData = (id, params) => {
    return getRequest(`/manager/goods/categoryParameters/${id}`, params)
}

//查询商品绑定参数信息
export const getCategoryParamsByGoodsId = (goodsId, categoryId) => {
    return getRequest(`/manager/goods/parameters/${goodsId}/${categoryId}`)
}
//保存参数
export const insertGoodsParams = (params) => {
    return postRequest('/manager/goods/parameters', params)
}
//更新参数
export const updateGoodsParams = (params) => {
    return putRequest('/manager/goods/parameters', params)
}
//删除参数
export const deleteParams = (id, params) => {
    return deleteRequest(`/manager/goods/parameters/${id}`, params)
}
//保存参数组
export const insertParamsGroup = (params) => {
    return postRequest('/manager/goods/categoryParameters', params)
}
//更新参数组
export const updateParamsGroup = (params) => {
    return putRequest('/manager/goods/categoryParameters', params)
}
//删除参数组
export const deleteParamsGroup = (id, params) => {
    return deleteRequest(`/manager/goods/categoryParameters/${id}`, params)
}

//保存获取关联规格
export const getGoodsSpecInfo = (category_id, params) => {
    return getRequest(`/manager/goods/categorySpec/goods/${category_id}`, params)
}


//获取sku列表
export const getSkuPage = (params) => {
  return getRequest(`/manager/goodsSku/getByPage`, params)
}






// 获取订单统计图表
export const getOrderChart = (params) => {
  return getRequest(`/manager/statistics/order`, params)
}


// 订单统计概览
export const getOrderOverView = (params) => {
  return getRequest(`/manager/statistics/order/overview`, params)
}

// 统计相关订单统计

export const statisticsOrderList = (params) => {
  return getRequest(`/manager/statistics/order/order`, params)
}

// 统计相关退单统计

export const statisticsOrderRefundList = (params) => {
  return getRequest(`/manager/statistics/order/refund`, params)
}


// 获取行业统计列表
export const goodsCategoryStatistics = (params) => {
    return getRequest(`/manager/statistics/goods/getCategoryByPage`, params)
}

// 获取统计列表,排行前一百的数据
export const goodsStatistics = (params) => {
    return getRequest(`/manager/statistics/goods`, params)
}


// 获取退款统计列表
export const refundStatistics = (params) => {
    return getRequest(`/manager/statistics/refund/order/getByPage`, params)
}

// 获取退款统计金额
export const refundPriceStatistics = (params) => {
    return getRequest(`/manager/statistics/refund/order/getPrice`, params)
}
